home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2007 June
/
PCWorld_2007-06_cd.bin
/
system
/
sandra
/
san1135.exe
/
{app}
/
examples
/
mySQL Schema.sql
< prev
next >
Wrap
Text File
|
2006-12-24
|
4KB
|
176 lines
#
# mySQL 3.23+/4.0+ Schema for Sandra Report (Unicode)
#
# Database is assumed to have been created already.
# No size settings included, please add as required.
#
# Copyright (c) 1995-2007, SiSoftware Ltd.
# All Rights Reserved.
#
# Kill all tables
#
DROP TABLE TItem;
DROP TABLE TControl;
DROP TABLE TItemGroup;
DROP TABLE TDevice;
DROP TABLE TClass;
DROP TABLE TModule;
DROP TABLE TReport;
DROP TABLE TIDCount;
#
# Create new tables
#
CREATE TABLE TReport (
ID INT PRIMARY KEY,
ProgVersion INT NOT NULL,
BuildVersion INT NOT NULL,
Completed BIT NOT NULL
);
CREATE TABLE TModule (
ID INT PRIMARY KEY,
ReportID INT NOT NULL,
Capabilities INT NOT NULL,
Name VARCHAR(255) NOT NULL,
TypeID INT NOT NULL,
HelpID INT NOT NULL,
CONSTRAINT cnstMRID FOREIGN KEY(ReportID) REFERENCES TReport(ID)
) CHARACTER SET ucs2;
CREATE TABLE TClass (
ID INT PRIMARY KEY,
ModuleID INT NOT NULL,
Name VARCHAR(255) NOT NULL,
IconID INT NOT NULL,
HelpID INT NOT NULL,
CONSTRAINT cnstCMID FOREIGN KEY(ModuleID) REFERENCES TModule(ID)
) CHARACTER SET ucs2;
CREATE TABLE TDevice (
ID INT PRIMARY KEY,
ModuleID INT NOT NULL,
ClassID INT,
Name VARCHAR(255) NOT NULL,
IconID INT NOT NULL,
HelpID INT NOT NULL,
CONSTRAINT cnstDMID FOREIGN KEY(ModuleID) REFERENCES TModule(ID),
CONSTRAINT cnstDCID FOREIGN KEY(ClassID) REFERENCES TClass(ID)
) CHARACTER SET ucs2;
CREATE TABLE TItemGroup (
ID INT PRIMARY KEY,
ModuleID INT NOT NULL,
ClassID INT,
DeviceID INT,
Name VARCHAR(255) NOT NULL,
IconID INT NOT NULL,
HelpID INT NOT NULL,
CONSTRAINT cnstGMID FOREIGN KEY(ModuleID) REFERENCES TModule(ID),
CONSTRAINT cnstGCID FOREIGN KEY(ClassID) REFERENCES TClass(ID),
CONSTRAINT cnstGDID FOREIGN KEY(DeviceID) REFERENCES TDevice(ID)
) CHARACTER SET ucs2;
CREATE TABLE TItem (
ID INT PRIMARY KEY,
ModuleID INT NOT NULL,
ClassID INT,
DeviceID INT,
GroupID INT,
Name VARCHAR(255) NOT NULL,
DataValue VARCHAR(255),
IconID INT NOT NULL,
TypeID INT NOT NULL,
HelpID INT NOT NULL,
CONSTRAINT cnstIMID FOREIGN KEY(ModuleID) REFERENCES TModule(ID),
CONSTRAINT cnstICID FOREIGN KEY(ClassID) REFERENCES TClass(ID),
CONSTRAINT cnstIDID FOREIGN KEY(DeviceID) REFERENCES TDevice(ID),
CONSTRAINT cnstIGID FOREIGN KEY(GroupID) REFERENCES TItemGroup(ID)
) CHARACTER SET ucs2;
CREATE TABLE TControl (
ID INT PRIMARY KEY,
ModuleID INT NOT NULL,
ClassID INT,
DeviceID INT,
Name INT NOT NULL,
DataValID INT NOT NULL,
DataValue VARCHAR(255),
CONSTRAINT cnstTMID FOREIGN KEY(ModuleID) REFERENCES TModule(ID),
CONSTRAINT cnstTCID FOREIGN KEY(ClassID) REFERENCES TClass(ID),
CONSTRAINT cnstTDID FOREIGN KEY(DeviceID) REFERENCES TDevice(ID)
) CHARACTER SET ucs2;
CREATE TABLE TIDCount (
TableName VARCHAR(10) PRIMARY KEY,
CurrentID INT NOT NULL
) CHARACTER SET ucs2;
#
# Set-up keys/indexes
#
CREATE INDEX ndxModuleParent ON TModule(ReportID);
CREATE INDEX ndxModuleType ON TModule(TypeID);
CREATE INDEX ndxClassParent ON TClass(ModuleID);
CREATE INDEX ndxClassType ON TClass(IconID);
CREATE INDEX ndxDeviceParent ON TDevice(ModuleID, ClassID);
CREATE INDEX ndxDeviceType ON TDevice(IconID);
CREATE INDEX ndxGroupParent ON TItemGroup(ModuleID, ClassID, DeviceID);
CREATE INDEX ndxGroupType ON TItemGroup(IconID);
CREATE INDEX ndxItemParent ON TItem(ModuleID, ClassID, DeviceID, GroupID);
CREATE INDEX ndxItemType ON TItem(IconID);
CREATE INDEX ndxControlParent ON TControl(ModuleID, ClassID, DeviceID);
CREATE INDEX ndxControlType ON TControl(Name);
CREATE INDEX ndxIDCount ON TIDCount(TableName);
#
# Inserts
#
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TItem', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TControl', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TItemGroup', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TDevice', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TClass', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TModule', 1);
INSERT INTO TIDCount (TableName, CurrentID) VALUES ('TReport', 1);